package ms.unicorn.utils;

import org.eclipse.ui.console.MessageConsoleStream;

public class Console {

	private static MessageConsoleStream consoleStream;
	
	public static void setMessageConsoleStream(MessageConsoleStream stream) {
		consoleStream = stream;
	}
	
	public static void printf(String message, Object...args) {
		if (consoleStream != null)
			consoleStream.print(String.format(message, args));
		else
			System.out.printf(message, args);
	}
	
	public static void println(String message, Object...args) {
		String msg = args.length > 0 ? String.format(message, args) : message;
		
		if (consoleStream != null)
			consoleStream.println(msg);
		else
			System.out.println(msg);
	}
	
	public static void println(Object e) {
		if (consoleStream != null)
			consoleStream.println(String.valueOf(e));
		else
			System.out.println(String.valueOf(e));
	}
	
	public static void println() {
		if (consoleStream != null)
			consoleStream.println();
		else
			System.out.println();
	}
}
